#include <cstdio>
#include <string>
#include <vector>
#include <string.h>
using namespace std;


class Matcher
{
	string pattern;
	vector<int> next;

public:
	Matcher( const char* p ): pattern(p), next(pattern.size() + 1, 0)
	{
		next[0] = -1;
		int j = -1;
		int i = 0;
		while( i < (int)pattern.size() )
		{
			if( j == -1 || pattern[i] == pattern[j] )
			{
				++i;
				++j;
				next[i] = j;
			}
			else
			{
				j = next[j];
			}
		}
	}

	int Search( const char* target )
	{
		int len = strlen( target );
		int j = 0;
		int i = -1;
		while( j < (int)pattern.size() && i < len )
		{
			if( j == -1 || pattern[j] == target[i] )
			{
				++i;
				++j;
			}
			else
			{
				j = next[j];
			}
		}

		if( j == (int)pattern.size() )
			return i - j;
		else
			return -1;
	}

};

int main()
{
	char pattern[1024] = {0};
	char target[1024] = {0};
	gets( pattern );
	gets( target );

	Matcher matcher( pattern );
	
	int p1 = matcher.Search( target );
	char* p = strstr( target, pattern );
	int p2 = p == NULL ? -1 : p - target;
	printf( "%d\n%d\n", p1, p2 );
	return 0;
}